#include <iostream>
#include <string>
using namespace std;

const int kMaxN = 2010;
const int kInf = 1e9;

int dp[kMaxN][kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s1, s2;

  cin >> s1 >> s2;
  for (int i = 0; i <= s1.size(); i++) {
    fill(dp[i], dp[i] + s2.size() + 1, kInf);
  }
  dp[0][0] = 0;
  for (int i = 0; i <= s1.size(); i++) {
    for (int j = 0; j <= s2.size(); j++) {
      if (dp[i][j] == kInf) {
        continue;
      }
      if (i != s1.size() && j != s2.size()) {
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (s1[i] != s2[j]));
      }
      if (i != s1.size()) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
      }
      if (j != s2.size()) {
        dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
      }
    }
  }
  cout << dp[s1.size()][s2.size()] << "\n";
  return 0;
}